<!--
 * @Description: 
 * @Version: 2.0
 * @Autor: zhangjx
 * @Date: 2023-05-31 16:49:00
 * @LastEditors: uphldjx 1373577124@qq.com
 * @LastEditTime: 2023-10-21 09:55:53
-->
<template>
	<BaseContainer style="--w-left-gap: 30rem">
		<template #left>
			<UnitTree @node-click="handleNodeClick" :paramsObj="paramsObj" placeholder="请输入组织名称"></UnitTree>
		</template>
		<aplid-base-crud
			ref="crud"
			v-bind="baseConfig"
			:formConfig="formConfig"
			:paramsObj="paramsObj"
			:operateFormate="operateFormate"
			:saveFormate="saveFormate"
		>
			<template v-slot:lockFlag="{ row }">
				<el-switch
					:model-value="row.lockFlag"
					class="ml-2"
					inline-prompt
					@click.native="onChange(row, 'lockFlag')"
					active-value="0"
					inactive-value="9"
					style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
					active-text="正常"
					inactive-text="停用"
				/>
			</template>

			<template v-slot:detailDialog="{ row }">
				<UserArchives
					:paramsObj="paramsObj"
					:api="baseConfig.api"
					:nowRowData="row"
					:formConfig="formConfig"
					:detailConfig="detailConfig"
					@refresh="handleRefresh"
				></UserArchives>
			</template>
		</aplid-base-crud>
	</BaseContainer>
</template>

<script setup lang="ts">
import UnitTree from '../components/UnitTree/index.vue'
import UserArchives from '../components/UserArchives/index.vue'
import { baseConfig, formConfig, detailConfig } from './config'
import { UserCommonHooks } from '../hooks/index'
import { useCommonStore } from '@/stores/common'
import { getStore } from '@/utils/store'

const { setGloablParams } = useCommonStore()
const crud = ref(null)
const userInfo = getStore('userInfo') || {}
const paramsObj: any = ref({
	classifyId: 4,
	authProvince: userInfo.authProvince,
	authCity: userInfo.authCity,
	authArea: userInfo.authArea,
	authStreet: userInfo.authStreet,
	authCommunity: userInfo.authCommunity,
})
const { operateFormate, handleNodeClick, onChange, handleRefresh, saveFormate } = UserCommonHooks(paramsObj.value, crud, '请先点击左边选择服务组织')

onUnmounted(() => {
	setGloablParams({})
})
</script>

<style scoped></style>
